<template>



  <el-form ref="form" :model="form" label-width="80px">
    <el-form-item label="账号">
      <el-input v-model="form.username"></el-input>
    </el-form-item>

    <el-form-item label="密码"    >
      <el-input v-model="form.password"  :type="pwdType" ></el-input>
    </el-form-item>

    <el-form-item>
      <el-button type="primary"  :loading="loading" @click="onSubmit">登录</el-button>
    </el-form-item>
  </el-form>



    
</template>

<script>
  import {setSupport,getSupport,setCookie,getCookie} from '@/utils/support';

  export default {
    data() {
      return {
        form: {
          username: '',
          password: '',
        },
        loading: false,
        pwdType: 'password'
      }
    },
    methods: {
      onSubmit() {
        console.log('submit!');
        this.$store.dispatch('Login', this.form).then(() => {
          this.loading = false;
          setCookie("username",this.form.username,15);
          setCookie("password",this.form.password,15);
          this.$router.push({path: '/'})
        }).catch(() => {
          this.loading = false
        })
      }
    }
  }
</script>

<style scoped>

</style>
